package com.example.myapp;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * Created by 艳双 on 2015/12/21.
 * project:myapp
 * user:lisa[FR]
 * Date:2015/12/21
 */
public class EmptyView extends LinearLayout {
    private TextView mEmptyText;
    private ImageView mEmptyIcon;

    public EmptyView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initialize();
    }

    public EmptyView(Context context) {
        super(context);
        initialize();
    }

    private void initialize() {
        inflate();
        basicSetting();
        findViews();
    }

    private void basicSetting() {
        setOrientation(HORIZONTAL);
        setGravity(Gravity.CENTER);
    }

    private void findViews() {
        mEmptyIcon = (ImageView) findViewById(R.id.emptyIcon);
        mEmptyText = (TextView) findViewById(R.id.emptyText);
    }

    private void inflate() {
        LayoutInflater.from(getContext()).inflate(R.layout.view_empty, this,
                true);
    }

    public void setEmptyText(int resId) {
        mEmptyText.setText(resId);
    }

    public void setEmptyIcon(int resId) {
        mEmptyIcon.setImageResource(resId);
    }
}
